package org.example.util;

import org.springframework.stereotype.Component;

@Component
public class ResponseData {

    private Integer code;
    private Object data;
    private Integer count;
    private String msg = "";

    public ResponseData() {
    }

    public ResponseData(Integer code, Object data, Integer count, String msg) {
        this.code = code;
        this.data = data;
        this.count = count;
        this.msg = msg;
    }

    public static ResponseData getJsonData(Object data, int count) {
        ResponseData responseData = new ResponseData();
        responseData.setCode(0);
        responseData.setData(data);
        responseData.setCount(count);

        return responseData;
    }

    public static ResponseData getSccesss(String msg, int code) {
        ResponseData responseData = new ResponseData();

        responseData.setMsg(msg);
        responseData.setCode(code);

        return responseData;
    }

    public static ResponseData error(String msg, int code) {
        ResponseData responseData = new ResponseData();

        responseData.setData(msg);
        responseData.setCode(code);

        return responseData;
    }

    public static ResponseData allResponse(Object data,String msg, int code,int count) {
        ResponseData responseData = new ResponseData();
        responseData.setData(data);
        responseData.setCount(count);
        responseData.setMsg(msg);
        responseData.setCode(code);

        return responseData;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }



}
